<?php

class WvideoController extends OAuth2Controller {
    protected $app_type = 'video';
    /**
     * 视频列表
     */
    public function actionList() {
        /*if (empty($this->userId)) {
            $this->error('未授权，无法访问');
        }

        $user = User::model()->findByPk($this->userId);
        if ($user === null) {
            $this->error('微信用户不存在');
        }*/
        $pid = Yii::app()->request->getParam('pid');
        if (empty($pid)) {
            $this->error('参数非法');
        }
        if (Yii::app()->request->isAjaxRequest) {
            $pid = Yii::app()->request->getParam('pid');
            $keyword = Yii::app()->request->getParam('keyword');
            $page = Yii::app()->request->getParam('page',1);
            $model = Video::model();
            $model->pid = $pid;
            $model->title = $keyword;
            $video_list = $model->getPageList($page);
            $data = array(
                'code' => 0,
                'data' => $video_list
            );
            $this->jsonResponse($data);
        } else {
            $floder  = Floder::model()->findByPk($pid);
            $this->render('list', array('floder'=>$floder));
        }
    }
}